package com.springboot.news.mapper;

import com.springboot.news.domain.po.Article;
import com.springboot.news.domain.po.Category;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ArticleMapper {
    @Insert("insert into article(title, content, cover_img, status, create_user, category_id, create_time, update_time)" +
            " values(#{title},#{content},#{coverImg},#{status},#{createUser},#{categoryId},#{createTime},#{updateTime})")
    void add(Article article);
    @Select("select * from article where id=#{id}")
    List<Article> list(@Param("userId") Integer userId, @Param("categoryId") Integer categoryId, @Param("status") String status);
    @Delete("delete from article where id=#{id}")
    void delete(@Param("id") Integer id);
    @Select("select * from article where id=#{id}")
    Article detail(@Param("id") Integer id);

    @Insert("update article set title=#{title},content=#{content},status=#{status},category_id=#{categoryId},cover_img=#{coverImg},update_time=now() where id=#{id}")
    void update(Article article);
}

